<template>
  <div>
    <!-- 消息弹框 -->
    <div>
      <Modal
        @on-cancel="cancel"
        class="Modalcss"
        v-model="newNews"
        :title="newNewsTitle"
      >
        <div style="margin-top: -10px; width: 500px">
          <div style="font-weight: 600; margin-bottom: 15px">
            {{ newsData.title }}
          </div>
          <div
            style="
              width: 500px;
              padding-right: 10px;
              display: block;
              word-break: break-all;
              word-wrap: break-word;
              margin-bottom: 55px;
            "
            v-html="newsData.content"
          >
            {{ newsData.content }}
          </div>
        </div>
        <div
          style="display: flex; justify-content: center; margin-bottom: -30px"
        >
          <Button @click="read()" class="but-left">我知道了</Button>
        </div>
        <div slot="footer"></div>
      </Modal>
    </div>
  </div>
</template>

<script>
import { modifyReadState } from "@/api/home";
export default {
  data() {
    return {
      newNews: this.newNews,
      newNewsTitle: "平台公告",
    };
  },
  props: {
    newNews: {
      type: Boolean,
      default: false,
    },
    newsData: {
      type: Object,
      default: "",
    },
  },
  watch: {
    newNews(val) {
      if (val.type == 1) {
        this.newNewsTitle = "平台公告";
      } else if (val.type == 2) {
        this.newNewsTitle = "业务消息";
      } else if (val.type == 3) {
        this.newNewsTitle = "认证消息";
      } else if (val.type == 4) {
        this.newNewsTitle = "系统通知";
      }
    },
  },
  created() {

  },
  mounted() {},
  methods: {
    // 我知道了
    read() {
      modifyReadState({ mesId: this.newsData.id }).then((res) => {
        if (res.code == 200) {
          this.$Message.success("消息已读");
          this.newNews = false;
          // location.reload();
        }
      });
    },
    // 关闭
    cancel() {
      this.$emit("newsEnd", this.newNews);
    },
  },
};
</script>

<style lang="less">
.but-left {
  margin-left: -10px;
  background-color: #19be6b !important;
  color: #fff !important;
  border: 0 !important;
}
.Modalcss {
  .ivu-modal-header {
    border-bottom: 0px !important;
  }
  .ivu-modal-footer {
    border-top: 0px !important;
  }
  .ivu-modal-header-inner {
    font-size: 16px !important;
    font-weight: 600 !important;
  }
}
</style>